package cn.homework.egmvc2.controller;

import cn.homework.egmvc2.mapper.AddressMapper;
import cn.homework.egmvc2.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;

    @RequestMapping("/insert")
    public String getAddress(Address address){
        int result =  addressMapper.insertAddress(address);
        return "success";
    }

    @RequestMapping("/select")
    public List<Address> addressList(){
        return addressMapper.selectAddress();
    }

    @RequestMapping("/delete")
    public String deleteAddress(Integer id){
        addressMapper.deleteAddress(id);
        return "success";
    }

    @RequestMapping("/update")
    public String updateAddress(Address address){
        addressMapper.updateAddress(address);
        return "success";
    }
}
